<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>git学习手册 | Leonの博客</title><meta name="keywords" content="git"><meta name="author" content="Leon"><meta name="copyright" content="Leon"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><meta name="description" content="学习git的CRUD的一些心得">
<meta property="og:type" content="article">
<meta property="og:title" content="git学习手册">
<meta property="og:url" content="https://gitee.com/Rickest_Rick/rickest_rick.git/2020/09/16/git/index.html">
<meta property="og:site_name" content="Leonの博客">
<meta property="og:description" content="学习git的CRUD的一些心得">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://pic.downk.cc/item/5ff71f043ffa7d37b377c2d9.jpg">
<meta property="article:published_time" content="2020-09-15T16:00:00.000Z">
<meta property="article:modified_time" content="2020-09-15T16:00:00.000Z">
<meta property="article:author" content="Leon">
<meta property="article:tag" content="git">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://pic.downk.cc/item/5ff71f043ffa7d37b377c2d9.jpg"><link rel="shortcut icon" href="/rickest_rick/img/favicon.png"><link rel="canonical" href="https://gitee.com/Rickest_Rick/rickest_rick.git/2020/09/16/git/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/rickest_rick/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css"><script>var GLOBAL_CONFIG = { 
  root: '/rickest_rick/',
  hexoversion: '5.1.1',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  ClickShowText: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"bottom-left"},
  justifiedGallery: {
    js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
    css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
  },
  isPhotoFigcaption: true,
  islazyload: false,
  isanchor: false
};

var saveToLocal = {
  set: function setWithExpiry(key, value, ttl) {
    const now = new Date()
    const expiryDay = ttl * 86400000
    const item = {
      value: value,
      expiry: now.getTime() + expiryDay,
    }
    localStorage.setItem(key, JSON.stringify(item))
  },

  get: function getWithExpiry(key) {
    const itemStr = localStorage.getItem(key)

    if (!itemStr) {
      return undefined
    }
    const item = JSON.parse(itemStr)
    const now = new Date()

    if (now.getTime() > item.expiry) {
      localStorage.removeItem(key)
      return undefined
    }
    return item.value
  }
}</script><script id="config_change">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isSidebar: true,
  postUpdate: '2020-09-16 00:00:00'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(function () {
  window.activateDarkMode = function () {
    document.documentElement.setAttribute('data-theme', 'dark')
    if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
    }
  }
  window.activateLightMode = function () {
    document.documentElement.setAttribute('data-theme', 'light')
    if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
    }
  }

  const autoChangeMode = 'false'
  const t = saveToLocal.get('theme')
  if (autoChangeMode === '1') {
    const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
    const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
    const isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
    const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified

    if (t === undefined) {
      if (isLightMode) activateLightMode()
      else if (isDarkMode) activateDarkMode()
      else if (isNotSpecified || hasNoSupport) {
        const now = new Date()
        const hour = now.getHours()
        const isNight = hour <= 6 || hour >= 18
        isNight ? activateDarkMode() : activateLightMode()
      }
      window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
        if (saveToLocal.get('theme') === undefined) {
          e.matches ? activateDarkMode() : activateLightMode()
        }
      })
    } else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else if (autoChangeMode === '2') {
    const now = new Date()
    const hour = now.getHours()
    const isNight = hour <= 6 || hour >= 18
    if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
    else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else {
    if (t === 'dark') activateDarkMode()
    else if (t === 'light') activateLightMode()
  }
})()</script><style type="text/css">#toggle-sidebar {bottom: 80px}</style><div class="aplayer" data-id="2693598459" data-server="netease" data-type="playlist" data-fixed="true" data-listFolded="false" data-order="random" data-preload="none"></div><link rel="stylesheet" href="https://cdn.bootcss.com/aplayer/1.10.1/APlayer.min.css"><script src="https://cdn.bootcss.com/aplayer/1.10.1/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/npm/meting@1.2.0/dist/Meting.min.js"></script><meta name="generator" content="Hexo 5.1.1"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="mobile-sidebar"><div id="menu_mask"></div><div id="mobile-sidebar-menus"><div class="mobile_author_icon"><img class="avatar-img" src="https://p.pstatp.com/origin/1393c0000008cd9a00a6f" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="mobile_post_data"><div class="mobile_data_item is-center"><div class="mobile_data_link"><a href="/rickest_rick/archives/"><div class="headline">文章</div><div class="length_num">3</div></a></div></div><div class="mobile_data_item is-center">      <div class="mobile_data_link"><a href="/rickest_rick/tags/"><div class="headline">标签</div><div class="length_num">3</div></a></div></div><div class="mobile_data_item is-center">     <div class="mobile_data_link"><a href="/rickest_rick/categories/"><div class="headline">分类</div><div class="length_num">2</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/rickest_rick/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/rickest_rick/archives/"><i class="fa-fw fas fa-archive"></i><span> 事件轴</span></a></div><div class="menus_item"><a class="site-page" href="/rickest_rick/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/rickest_rick/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> List</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/rickest_rick/music/"><i class="fa-fw fas fa-music"></i><span> Music</span></a></li><li><a class="site-page" href="/rickest_rick/bangumis/"><i class="fa-fw fas fa-video"></i><span> 追番列表</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/rickest_rick/link/"><i class="fa-fw fas fa-link"></i><span> 友情链接</span></a></div><div class="menus_item"><a class="site-page" href="/rickest_rick/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div id="body-wrap"><div id="sidebar"><i class="fas fa-arrow-right on" id="toggle-sidebar"></i><div class="sidebar-toc"><div class="sidebar-toc__title">目录</div><div class="sidebar-toc__progress"><span class="progress-notice">你已经读了</span><span class="progress-num">0</span><span class="progress-percentage">%</span><div class="sidebar-toc__progress-bar">     </div></div><div class="sidebar-toc__content"><ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%9B%86%E4%B8%AD%E5%BC%8F-svn"><span class="toc-number">1.</span> <span class="toc-text">集中式(svn)</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%86%E5%B8%83%E5%BC%8F-git"><span class="toc-number">2.</span> <span class="toc-text">分布式(git)</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9B%BE%E8%A7%A3"><span class="toc-number">3.</span> <span class="toc-text">图解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%AB%98%E5%B1%82%E5%91%BD%E4%BB%A4"><span class="toc-number">4.</span> <span class="toc-text">高层命令</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#sshkey"><span class="toc-number">4.1.</span> <span class="toc-text">sshkey</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B3%E8%81%94%E8%BF%9C%E7%A8%8B"><span class="toc-number">5.</span> <span class="toc-text">关联远程</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#git-Conflict%E8%A7%A3%E5%86%B3%E5%86%B2%E7%AA%81"><span class="toc-number">6.</span> <span class="toc-text">git Conflict解决冲突</span></a></li></ol></div></div></div><header class="post-bg" id="page-header" style="background-image: url(https://pic.downk.cc/item/5ff71f043ffa7d37b377c2d9.jpg)"><nav id="nav"><span id="blog_name"><a id="site-name" href="/rickest_rick/">Leonの博客</a></span><span id="menus"><div id="search_button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/rickest_rick/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/rickest_rick/archives/"><i class="fa-fw fas fa-archive"></i><span> 事件轴</span></a></div><div class="menus_item"><a class="site-page" href="/rickest_rick/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/rickest_rick/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> List</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/rickest_rick/music/"><i class="fa-fw fas fa-music"></i><span> Music</span></a></li><li><a class="site-page" href="/rickest_rick/bangumis/"><i class="fa-fw fas fa-video"></i><span> 追番列表</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/rickest_rick/link/"><i class="fa-fw fas fa-link"></i><span> 友情链接</span></a></div><div class="menus_item"><a class="site-page" href="/rickest_rick/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><span class="close" id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></span></span></nav><div id="post-info"><div id="post-title"><div class="posttitle">git学习手册</div></div><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2020-09-15T16:00:00.000Z" title="发表于 2020-09-16 00:00:00">2020-09-16</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2020-09-15T16:00:00.000Z" title="更新于 2020-09-16 00:00:00">2020-09-16</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/rickest_rick/categories/%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6%E5%B7%A5%E5%85%B7/">版本控制工具</a></span></div><div class="meta-secondline"> <span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.2k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>4分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout_post" id="content-inner"><article id="post"><div class="post-content" id="article-container"><h3 id="集中式-svn"><a href="#集中式-svn" class="headerlink" title="集中式(svn)"></a>集中式(svn)</h3><p>svn因为每次存储的都是差异 需要的磁盘空间相对会小一些  可是回滚的速度会很慢</p>
<p>优点：</p>
<p>​        代码存放在单一的服务器上便于项目的管理</p>
<p>缺点：</p>
<p>​        服务器宕机：员工的代码得不到保障</p>
<p>​        服务器炸了：整个项目的历史纪录都会丢失</p>
<h3 id="分布式-git"><a href="#分布式-git" class="headerlink" title="分布式(git)"></a>分布式(git)</h3><p>缺点:</p>
<p>git 每次存的都是项目的完整快照 需要的硬盘空间会相对大一些</p>
<p>学习路线陡峭</p>
<p>回滚速度快(git团队对代码做了极致的压缩所以实际的空间也比svn大不了多少)</p>
<h3 id="图解"><a href="#图解" class="headerlink" title="图解"></a>图解</h3><p><img src="https://i.loli.net/2020/10/04/jkqc6JBUZIbDQ38.png" alt="git工作流.png"></p>
<h3 id="高层命令"><a href="#高层命令" class="headerlink" title="高层命令"></a>高层命令</h3><p><strong>###安装</strong></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git --version</span><br></pre></td></tr></table></figure>



<p><strong>###初始化仓库</strong></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git init</span><br></pre></td></tr></table></figure>



<p><strong>###初始化</strong></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git config --global user.name &quot;admin&quot;</span><br><span class="line"></span><br><span class="line">git config --global user,email &quot;admin@example.com&quot;</span><br><span class="line"></span><br><span class="line">git config --list   &#x2F;&#x2F;查看配置历史</span><br></pre></td></tr></table></figure>



<p><strong>###区域</strong></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">working directory 工作区</span><br><span class="line"></span><br><span class="line">staging index 暂存区</span><br><span class="line"></span><br><span class="line">git directory 版本库</span><br></pre></td></tr></table></figure>



<p><strong>###c(新增)</strong></p>
<p>在工作目录中新增文件</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git status </span><br><span class="line"></span><br><span class="line">git add .&#x2F;</span><br><span class="line"></span><br><span class="line">git commit -m &quot;msg&quot;</span><br></pre></td></tr></table></figure>



<p><strong>###u(修改)</strong></p>
<p>在工作目录中修改文件</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git status </span><br><span class="line"></span><br><span class="line">git add .&#x2F;</span><br><span class="line"></span><br><span class="line">git commit -m &quot;msg&quot;</span><br></pre></td></tr></table></figure>



<p><strong>###d(删除 &amp; 重命名)</strong></p>
   <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git rm  要删除的文件</span><br><span class="line"></span><br><span class="line">git status </span><br><span class="line"></span><br><span class="line">git commit -m &quot;msg&quot;</span><br><span class="line"></span><br><span class="line">git mv 老文件 新文件</span><br></pre></td></tr></table></figure>



<p><strong>###R(查询)</strong></p>
  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git status  : 查看工作目录中文件的状态(以跟踪，已提交，已暂存，已修改)</span><br><span class="line"></span><br><span class="line">git diff       : 查看未缓存的修改</span><br><span class="line"></span><br><span class="line">git diff --cache: 查看未提交的缓存    </span><br><span class="line"></span><br><span class="line">git log --oneline: 查看提交纪录</span><br><span class="line"></span><br><span class="line">git reflog:            保留前7位哈希值的简短日志</span><br><span class="line"></span><br><span class="line">git* reset --hard &lt;commit id&gt;  回退到某个你指定的版本</span><br></pre></td></tr></table></figure>



<p><strong>###分支</strong></p>
<p>​    每次切换分支前一定要保证是干净的 git status查看是否已提交</p>
  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git log --oneline --decorate --graph --all :查看整个项目的分支图</span><br><span class="line"></span><br><span class="line">git branch : 查看分支列表</span><br><span class="line"></span><br><span class="line">git branch -a :查看远程和本地的所有分支</span><br><span class="line"></span><br><span class="line">git branch -v:查看分支指向最近的提交</span><br><span class="line"></span><br><span class="line">git branch -vv 查本地和远程分支关联</span><br><span class="line"></span><br><span class="line">git branch name: 在当前提交对象上创建新的分支</span><br><span class="line"></span><br><span class="line">git branch name commithash:在指定的提交对象上创建新的分支</span><br><span class="line"></span><br><span class="line">git checkout name: 切换分支</span><br><span class="line"></span><br><span class="line">git checkout -b &quot;name&quot; ：创建分支并且切换到该分支</span><br><span class="line"></span><br><span class="line">git branch -d name:删除已经合并的分支</span><br><span class="line"></span><br><span class="line">git branch -D name: 强制删除分支	</span><br></pre></td></tr></table></figure>



<p><strong>###存储</strong></p>
  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git stash 把当前的工作隐藏起来 等以后恢复现场后继续工作</span><br><span class="line"></span><br><span class="line">git stash list 查看所有被隐藏的文件列表</span><br><span class="line"></span><br><span class="line">git stash apply 恢复被隐藏的文件，但是内容不删除</span><br><span class="line"></span><br><span class="line">git stash drop 删除文件</span><br><span class="line"></span><br><span class="line">git stash pop 恢复文件的同时 也删除文件</span><br></pre></td></tr></table></figure>



<h4 id="sshkey"><a href="#sshkey" class="headerlink" title="sshkey"></a>sshkey</h4><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">ssh-keygen -t rsa -C “youremail&quot; 生成sshkye</span><br><span class="line"></span><br><span class="line">ls -al ~&#x2F;.ssh 查看ssh文件夹下面的所有文件</span><br><span class="line"></span><br><span class="line">cat ~&#x2F;.ssh&#x2F;id_rsa.pub 查看ssh key</span><br></pre></td></tr></table></figure>



<h3 id="关联远程"><a href="#关联远程" class="headerlink" title="关联远程"></a>关联远程</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git remote add origin https:&#x2F;&#x2F;gitee.com&#x2F;green_vegetables&#x2F;mi.git</span><br><span class="line"></span><br><span class="line">git pull --rebase origin master    拉取远程readme文件</span><br></pre></td></tr></table></figure>

<h3 id="git-Conflict解决冲突"><a href="#git-Conflict解决冲突" class="headerlink" title="git Conflict解决冲突"></a>git Conflict解决冲突</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">情景1:多个分支合并到一个分支上时。</span><br><span class="line">情景2:多个分支向同一个远端分支推送代码。</span><br><span class="line">实际上，push操作即是将本地代码merge到远端库分支上。</span><br><span class="line">关于push和pull其实就分别是用本地分支合并到远程分支 和 将远程分支合并到本地分支。。。</span><br></pre></td></tr></table></figure>

<p> <strong>1、先将本地修改存储起来</strong></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git stash</span><br></pre></td></tr></table></figure>

<p> 这样本地的所有修改就都被暂时存储起来 。<br> 其中stash@{0}就是刚才保存的标记。</p>
<p> 2、pull内容<br> 暂存了本地修改之后，就可以pull了。</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git pull</span><br></pre></td></tr></table></figure>

<p> 3、还原暂存的内容</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git stash list</span><br></pre></td></tr></table></figure>

<p>显示保存的工作进度列表，编号越小代表保存进度的时间越近。 git stash pop stash@{0}</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git stash pop stash@&#123;num&#125;&#96;</span><br></pre></td></tr></table></figure>

<p>恢复工作进度到工作区，此命令的stash@{num}是可选项，在多个工作进度中可以选择恢复，不带此项则默认恢复最近的一次进度相当于<code>git stash pop stash@&#123;0&#125;</code></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git stash apply stash@&#123;num&#125;&#96;</span><br></pre></td></tr></table></figure>

<p>恢复工作进度到工作区且该工作进度可重复恢复，此命令的stash@{num}是可选项，在多个工作进度中可以选择恢复，不带此项则默认恢复最近的一次进度相当于<code>git stash apply stash@&#123;0&#125;</code></p>
<p> 系统提示如下类似的信息：<br> Auto-merging c/environ.cCONFLICT (content): Merge conflict in c/environ.c<br> 意思就是系统自动合并修改的内容，但是其中有冲突，需要解决其中的冲突。</p>
<p> 4、解决文件中冲突的的部分<br> 打开冲突的文件，<br> 其中Updated upstream 和=====之间的内容就是pull下来的内容，====和stashed changes之间的内容就是本地修改的内容。碰到这种情况，git也不知道哪行内容是需要的，所以要自行确定需要的内容。</p>
<p>5.清除暂存</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">git stash clear</span><br></pre></td></tr></table></figure>

<p>删除所有暂存</p>
</div><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">xiaoluo</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://gitee.com/Rickest_Rick/rickest_rick.git/2020/09/16/git/">https://gitee.com/Rickest_Rick/rickest_rick.git/2020/09/16/git/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://gitee.com/Rickest_Rick/rickest_rick.git" target="_blank">Leonの博客</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/rickest_rick/tags/git/">git</a></div><div class="post_share"><div class="social-share" data-image="https://pic.downk.cc/item/5ff71f043ffa7d37b377c2d9.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏<div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/wechat.jpg" target="_blank"><img class="post-qr-code-img" src="/rickest_rick/img/wechat.jpg" alt="wechat"/></a><div class="post-qr-code-desc">wechat</div></li><li class="reward-item"><a href="/img/alipay.jpg" target="_blank"><img class="post-qr-code-img" src="/rickest_rick/img/alipay.jpg" alt="alipay"/></a><div class="post-qr-code-desc">alipay</div></li></ul></div></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-full"><a href="/rickest_rick/2020/10/03/My-new-post/"><img class="prev-cover" src="https://pic.downk.cc/item/5ff71e863ffa7d37b3776db6.jpg" onerror="onerror=null;src='/rickest_rick/img/404.jpg'"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">My new post</div></div></a></div></nav></article></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;undefined - 2021  <i id="heartbeat" class="fa fas fa-heartbeat"></i> Leon</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">Hi, welcome to my blog</div></div><head><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/HCLonely/images@master/others/heartbeat.min.css"></head?>       </footer></div><section id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">简</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="chat_btn" type="button" title="rightside.chat_btn"><i class="fas fa-sms"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></section><div class="search-dialog" id="local-search"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"><div id="local-hits"></div><div id="local-stats"><div class="local-search-stats__hr" id="hr"><span>由</span> <a target="_blank" rel="noopener" href="https://github.com/wzpan/hexo-generator-search" style="color:#49B1F5;">hexo-generator-search</a>
 <span>提供支持</span></div></div></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div><div><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script src="/rickest_rick/js/utils.js"></script><script src="/rickest_rick/js/main.js"></script><script src="/rickest_rick/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/rickest_rick/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',()=> {preloader.endLoading()})</script><div class="js-pjax"><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><canvas class="fireworks" mobile="true"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="true" data-click="true"></script><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="120" mobile="true" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = true;
document.body.addEventListener('input', POWERMODE);
</script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = [
  'title',
  '#config_change',
  '#body-wrap',
  '#rightside-config-hide',
  '#rightside-config-show',
  '.js-pjax'
]

if (false) {
  pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
}

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  $('script[data-pjax]').each(function () {
    $(this).parent().append($(this).remove())
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  if (typeof gtag === 'function') {
    gtag('config', '', {'page_path': window.location.pathname});
  }

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // Analytics
  if (false) {
    MtaH5.pgv()
  }

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})


document.addEventListener('pjax:send', function () {
  typeof preloader === 'object' && preloader.initLoading()
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  $(window).off('scroll')

  //reset readmode
  $('body').hasClass('read-mode') && $('body').removeClass('read-mode')

})</script></div><script src="/rickest_rick/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"log":false,"model":{"jsonPath":"/rickest_rick/live2dw/assets/assets/haru02.model.json"},"display":{"position":"right","width":200,"height":350,"hOffset":10,"vOffset":0},"mobile":{"show":true,"scale":0.5},"react":{"opacityDefault":0.7,"opacityOnHover":1}});</script></body></html>